Results 1 to 9 of 9

Thread: Headshot Only with Sniper (disable other hitbox areas)

  1. #1

    Default Headshot Only with Sniper (disable other hitbox areas)

    Is it possible when a player has a specific weapon to disable all hitboxes other than 0 1 and 2 (head, helmet and neck)? I want all weapons other than a sniper to be able to shoot anywhere and do damage, but when the player has a sniper - only headshots would do damage to the player. I've searched around and found one post on TMT that didn't go anywhere productive.. Any ideas here?
    Last edited by [cB]SplatterGuts; April 12th, 2015 at 11:09 PM.

  2. #2

    Default

    I guess this should work :

    for( local.i = 0; local.i < 18; local.i++ )
    {
        local.player damagemult local.i 0.0
    }
    
    local.player damagemult 4 10.0 // Head
    local.player damagemult 5 10.0 // Neck
    
    // Location values:
    // -1 General
    // 0 Pelvis
    // 1 Lower Torso
    // 2 Mid Torso
    // 3 Upper Torso
    // 4 Neck
    // 5 Head
    // 6 RUpperArm
    // 7 RForearm
    // 8 RHand
    // 9 LUpperArm
    // 10 LForearm
    // 11 LHand
    // 12 RThigh
    // 13 RCalf
    // 14 RFoot
    // 15 LThigh
    // 16 LCalf
    // 17 LFoot

  3. #3
    Purple Developer Purple Elephant1au's Avatar
    Join Date
    Feb 2012
    Location
    Australia
    Posts
    1,259

    Default

    Hi

    Just a question to clarify

    Do you want the player who is holding the sniper to be headshot only,
    OR
    Anyone who gets SHOT by the sniper, regardless of what weapon they are holding, is headshot.

    Purple's Playground
    OBJ :
    103.29.85.127:12203
    xfire: purpleelephant1au
    email: purpleelephant1au@gmail.com
    skydrive: PurpleElephantSkydrive




  4. #4

    Default

    for( local.i = 0; local.i < 18; local.i++ )
    	{
    		local.player damagemult local.i 0.0
    	}
    
    local.player damagemult 0 10.0 // Head
    local.player damagemult 1 10.0 // Helmet
    local.player damagemult 2 10.0 // Neck
    }


    Thanks!! This works, but it works on all of the weapons, not just the sniper rifle.

    I tried this under the spawned event to make it only work for the springfield:

    spawned local.attacker local.damage local.inflictor local.position local.direction local.normal local.knockback local.damageflags local.meansofdeath local.location local.player:
    
            local.player takeall
            local.player give models/weapons/springfield.tik
    	local.player give models/weapons/colt45.tik
            local.player useweaponclass rifle
    
    /// Makes sure both attacker and victim are players
    if(local.player.classname == "Player" && local.attacker.classname == "Player")
    {
        /// Loops through inventory
        for(local.i=0;local.i < local.attacker.inventory.size;local.i++)
        {
            /// stores weapon
            local.weapon = local.attacker.inventory[local.i]
    
            // Until finds weapons
            if(local.weapon.model == "models/weapons/springfield.tik")
            {
    for( local.i = 0; local.i < 18; local.i++ )
    			{
    				local.player damagemult local.i 0.0
    			}
    
    		local.player damagemult 0 10.0 // Head
    		local.player damagemult 1 10.0 // Helmet
    		local.player damagemult 2 10.0 // Neck
    		}
    }
    }
    }

    But it doesn't do anything different from the code you had posted.

    Note: I had to use the hit locations posted by PE in another post for them to work correctly

    Spoiler: [QUOTE=Purple Elephant1au;20547
    I am pretty sure those locations are incorrect
    Theres been 2 different sets of locations running around , and when i tested both of them , i found these ones to be accurate
    Code:
        -1 - General - ie:bash, rocket in the kisser, blown away, played catch, etc.. 
        0 - Head 
        1 - Helmet 
        2 - Neck 
        3 - Upper Torso 
        4 - Middle Torso 
        5 - Lower Torso 
        6 - Pelvis 
        7 - Upper Right Arm 
        8 - Upper Left Arm 
        9 - Upper Right Leg 
        10 - Upper Left Leg 
        11 - Lower Right Arm 
        12 - Lower Left Arm 
        13 - Lower Right Leg 
        14 - Lower Left Leg 
        15 - Right Hand 
        16 - Left Hand 
        17 - Right Foot 
        18 - Left Foot 
    


    why is that ?
    I have seen both but only ever seen this one to be the working one ?
    Does each one apply to a different entity or ?
    [/QUOTE]

    ]








    @PE -- The player who has a sniper in their hand, I want them to only be able to kill others by shooting them in the head, regardless of the other players weapon.
    Last edited by [cB]SplatterGuts; April 12th, 2015 at 11:09 PM.

  5. #5
    Purple Developer Purple Elephant1au's Avatar
    Join Date
    Feb 2012
    Location
    Australia
    Posts
    1,259

    Default

    Quote Originally Posted by BRATS-SplatterGuts View Post
    @PE -- The player who has a sniper in their hand, I want them to only be able to kill others by shooting them in the head, regardless of the other players weapon.
    Thats where it can get tricky, because the damagemult applies to the player, not to how the weapon reacts.

    So want you want is to apply the headshot only to players who get shot by the sniper, or remove damage to other locations if its the sniper shooting and only damage the player when its a headshot.

    A possible way to do this would be something like

    On spawn, set all other locations damagemult to 0.01 or something smallish but enough to cause like 1 damage so event is triggered, leave headshots as stock.
    Then on damage event, check which weapon was used to inflict the damage, if it is not the sniper and not a headshot, then applie the normal amount of damage to the player which they should of got if you didnt negate the damagemult.
    Does that make sense.

    Since you cant stop damage in its tracks on the event, but you could stop it with damagemult and just apply it later when you want to, only with certain conditions.

    So basically the process would be
    player gets shot(damaged since other body shots are not 1 hit kills)
    check if inflictors weapon is sniper >> if yes then dont apply any damage
    >> if no, then inflict the correct amount of damage that would of normally been applied to the player

    EDIT::

    Something like this,
    Note this is untested and might have spelling mistakes etc but its the general idea

    First on spawn event, set all damagemult to 0.1 or something small, but enough to trigger the damage event, on all locations BESIDES the headshot ones, ie 0,1,2

    then try this has the damage event
    damage local.target local.inflictor local.damage local.position local.direction local.normal local.knockback local.damageflags local.meansofdeath local.location local.entity:
    
    
    //Local.player will be the player who got damaged, idk if its target or entity
    local.player = local.entity
    ///local.player = local.target
    
    if(local.player.classname == "Player" && local.inflictor.classname == "Player")
    {
    
        /// If locations are head, helmet or neck, end because we didnt touch these damagemult locations
        if(local.location == 0 || local.location == 1 || local.location == 2)
        end
    
        // Gets current gun of the inflictor
        local.gun = local.inflictor getactiveweap 0
    
        /// If gun is a sniper end, because we want no damage to them ( you can always had the 1 hp back that is needed to be taken to trigger the event )
        if(local.gun.model == "models/weapons/springfield.tik" || local.gun.model == "models/weapons/kar98sniper.tik")
        end
    
    
        ////// find correct damagemult  /////
        //load array from thread
        local.damagemult_array = waitthread get_damagemult_array
    
        for(local.i = 1;local.i <= local.damagemult_array.size;local.i++)
        {
    
            if(local.location == local.damagemult_array[local.i][1])
            {
            local.normal_damagemult = local.damagemult_array[local.i][2]
            break;
            }
        }
    
        // i think its how you get the damage, Note if it cant be done this way then you will have to make an array with the damage per weapon, it might be Set varible only not read....
        /// Check above array and loop
        local.normal_bulletdamage = local.gun.dmbulletdamage
    
        // Calculate correct damage
        local.normal_damage = local.normal_bulletdamage * local.normal_damagemult
    
    
    ///damage( Entity attacker, Integer damage, Entity inflictor, Vector position, Vector direction, Vector normal, Integer knockback, Integer damageflags, Integer meansofdeath, Integer location )
    
        //apply damage
        // Target            /// Inflictor    /// Damage
        local.player damage local.inflictor local.normal_damage local.inflictor local.position local.direction local.normal local.knockback local.damageflags local.meansofdeath local.location
    
    
    }
    
    end
    
    get_damagemult_array:
    
    // Store stock damagemult values in array by location
    local.damagemult_array = makeArray
    //Location        // Value
    "-1"             "1.00"
    "0"             "2.00"
    "1"             "2.00"
    "2"             "2.00"
    "3"             "1.00"
    "4"             "0.95"
    "5"              "0.90"
    "6"             "0.85"
    "7"             "0.80"
    "8"             "0.80"
    "9"              "0.80"
    "10"              "0.80"
    "11"             "0.60"
    "12"              "0.60"
    "13"              "0.60"
    "14"              "0.60"
    "15"              "0.50"
    "16"             "0.50"
    "17"             "0.50"
    "18"             "0.50"
    endArray
    
    end local.damagemult_array


    OR

    As you stated in chat, you could just focus on snipers lol

    so start by setting both snipers dmbulletdamage to 1 or something small

    Then in damage event, check if a sniper weapon shot in the head, apply more damage to kill the player, thus if the weapon was not sniper, or not a headshot, it wont be touched

    damage local.target local.inflictor local.damage local.position local.direction local.normal local.knockback local.damageflags local.meansofdeath local.location local.entity:
    
    //Local.player will be the player who got damaged, idk if its target or entity
    local.player = local.entity
    ///local.player = local.target
    
    if(local.player.classname == "Player" && local.inflictor.classname == "Player")
    {
    
        /// If locations are head, helmet or neck
        if(local.location == 0 || local.location == 1 || local.location == 2)
        {
    
            // Gets current gun of the inflictor
            local.gun = local.inflictor getactiveweap 0
    
            /// If gun is a sniper apply 200 damage to kill them
            if(local.gun.model == "models/weapons/springfield.tik" || local.gun.model == "models/weapons/kar98sniper.tik")
            {
            //apply damage
            // Target            /// Inflictor    /// Damage
            local.player damage local.inflictor 200 local.inflictor local.position local.direction local.normal local.knockback local.damageflags local.meansofdeath local.location
            }
        }
    }
    
    end
    Last edited by Purple Elephant1au; April 13th, 2015 at 04:53 AM.

    Purple's Playground
    OBJ :
    103.29.85.127:12203
    xfire: purpleelephant1au
    email: purpleelephant1au@gmail.com
    skydrive: PurpleElephantSkydrive




  6. #6
    Über Prodigy & Developer Razo[R]apiD's Avatar
    Join Date
    May 2010
    Location
    Poland, Lublin
    Posts
    3,245

    Default

    You could also try to add <damage> health, because as far as I remember, damage event is executed before the rest of the damage logic, so health+damage-damage=health if you would want to omit some damage.

    But I'm not sure, you would need to try it.

  7. #7

    Default

    damage local.target local.inflictor local.damage local.position local.direction local.normal local.knockback local.damageflags local.meansofdeath local.location local.entity:
    
    //Local.player will be the player who got damaged, idk if its target or entity
    local.player = local.entity
    ///local.player = local.target
    
    if(local.player.classname == "Player" && local.inflictor.classname == "Player")
    {
    
        /// If locations are head, helmet or neck
        if(local.location == 0 || local.location == 1 || local.location == 2)
        {
    
            // Gets current gun of the inflictor
            local.gun = local.inflictor getactiveweap 0
    
            /// If gun is a sniper apply 200 damage to kill them
            if(local.gun.model == "models/weapons/springfield.tik")
            {
    		//apply damage
            // Target            /// Inflictor    /// Damage
            local.player damage local.inflictor 200 local.inflictor local.position local.direction local.normal local.knockback local.damageflags local.meansofdeath local.location
            }
        }
    }
    
    end


    This works perfectly. And I can set the dm weapon settings for this gametype (like how ckr is set in you weapon limiter mod basically) so that this can be used without messing up too much stuff on a server ;P You rock!

  8. #8
    Developer RyBack's Avatar
    Join Date
    Apr 2014
    Location
    In Front of the screen
    Posts
    1,566

    Default

    don't forget to add this statement :

    if he didn't got head shot heal the player ,
    i didn't read the whole post so idk if someone else noticed that :v

  9. #9

    Default

    We had mentioned that in chat, it never made it's way into the post however. It's in my script, so when I publish it, it'll be there! Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •